﻿<Window x:Class="XamlHelpmeet.UI.UIControlDefaultsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:rules="clr-namespace:XamlHelpmeet.UI.ValidationRules"
        xmlns:shell="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.11.0"
        Title="UI Control Default Settings"
        Width="650"
        Height="550"
        Background="{DynamicResource {x:Static shell:VsBrushes.WindowKey}}"
        BorderBrush="{DynamicResource {x:Static shell:VsBrushes.WindowFrameKey}}"
        Foreground="{DynamicResource {x:Static shell:VsBrushes.WindowTextKey}}"
        Loaded="UIControlDefaultsWindow_Loaded"
        ShowInTaskbar="True">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../UIResources.xaml" />
                <ResourceDictionary>
                    <rules:RequiredEntryValidationRule x:Key="requiredEntryValidationRule" />
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    
    <Grid>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!--  Control List on Left Side of Window  -->
        <StackPanel VerticalAlignment="Stretch">
            <TextBlock Margin="5"
                       FontSize="12"
                       Text="Platform Controls" />
            <ListBox x:Name="lbControls"
                     Width="Auto"
                     SelectionChanged="lbControls_SelectionChanged">
                <ListBox.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <TextBlock Margin="0,5,0,0"
                                           FontWeight="Bold"
                                           Padding="2,0,0,0"
                                           Text="{Binding Name}" />
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                    </GroupStyle>
                </ListBox.GroupStyle>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Margin="0,0,10,0"
                                   HorizontalAlignment="Left"
                                   VerticalAlignment="Center"
                                   Text="{Binding ControlRole}"
                                   TextWrapping="NoWrap" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </StackPanel>

        <!--  Control Settings Editor  -->
        <Border x:Name="bdrContainer"
                Grid.Column="1"
                BorderThickness="1"
                DataContext="{Binding SelectedItem,
                                      ElementName=lbControls}"
                Padding="10">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

                <Label Width="81"
                       HorizontalAlignment="Left"
                       Content="UI Platform:" />
                <Label Grid.Row="1"
                       Content="Control Role:" />
                <Label Grid.Row="2"
                       Content="Control Type:" />

                <TextBlock Grid.Column="1"
                           VerticalAlignment="Center"
                           Text="{Binding Platform}" />
                <TextBlock Grid.Row="1"
                           Grid.Column="1"
                           VerticalAlignment="Center"
                           Text="{Binding ControlRole}" />
                <TextBox Grid.Row="2"
                         Grid.Column="1"
                         VerticalAlignment="Center">
                    <TextBox.ToolTip>
                        <ToolTip>
                            <StackPanel>
                                <StackPanel.Resources>
                                    <Style TargetType="{x:Type TextBlock}">
                                        <Setter Property="Margin" Value="5" />
                                    </Style>
                                </StackPanel.Resources>
                                <TextBlock Text="Enter control type that you want created when this control role is created." />
                                <TextBlock Text="This feature enables you to have a control other than the platform default be created." />
                                <TextBlock Text="Example For WPF TextBox" />
                                <TextBlock FontWeight="Bold"
                                           Text="Default:  TextBox" />
                                <TextBlock FontWeight="Bold"
                                           Text="Custom:  local:CustomTextBox" />
                            </StackPanel>
                        </ToolTip>
                    </TextBox.ToolTip>
                    <Binding Mode="TwoWay"
                             Path="ControlType"
                             TargetNullValue=""
                             UpdateSourceTrigger="PropertyChanged"
                             ValidatesOnDataErrors="True"
                             ValidatesOnExceptions="True">
                        <Binding.ValidationRules>
                            <rules:RequiredEntryValidationRule />
                        </Binding.ValidationRules>
                    </Binding>
                </TextBox>

                <!--  + Check Box Options  -->
                <CheckBox x:Name="chkIncludeNotifyOnValidationError"
                          Grid.Row="3"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,3.5"
                          VerticalAlignment="Center"
                          Content="Include notify on validation errors"
                          IsChecked="{Binding IncludeNotifyOnValidationError,
                                              Mode=TwoWay,
                                              UpdateSourceTrigger=PropertyChanged}" />
                <CheckBox x:Name="chkIncludeValidatesOnDataErrors"
                          Grid.Row="4"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,3.5"
                          VerticalAlignment="Center"
                          Content="Include validates on data errors"
                          IsChecked="{Binding IncludeValidatesOnDataErrors,
                                              Mode=TwoWay,
                                              UpdateSourceTrigger=PropertyChanged}" />
                <CheckBox x:Name="chkIncludeValidatesOnExceptions"
                          Grid.Row="5"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,3.5"
                          VerticalAlignment="Center"
                          Content="Include validates on exceptions"
                          IsChecked="{Binding IncludeValidatesOnExceptions,
                                              Mode=TwoWay,
                                              UpdateSourceTrigger=PropertyChanged}" />
                <CheckBox x:Name="chkGenerateControlName"
                          Grid.Row="6"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,3.5"
                          VerticalAlignment="Center"
                          Content="Generate x:Name for control"
                          IsChecked="{Binding GenerateControlName,
                                              Mode=TwoWay,
                                              UpdateSourceTrigger=PropertyChanged}" />
                <CheckBox x:Name="chkIncludeTargetNullValueForNullableBindings"
                          Grid.Row="7"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,3.5"
                          VerticalAlignment="Center"
                          Content="Include TargetNullValue when source is nullable (applies to WPF/SL4 TextBox)"
                          IsChecked="{Binding IncludeTargetNullValueForNullableBindings,
                                              Mode=TwoWay,
                                              UpdateSourceTrigger=PropertyChanged}" />

                <!--  User Added Properties  -->
                <StackPanel Grid.Row="9"
                            Grid.ColumnSpan="2"
                            Margin="0,10,0,0">
                    <TextBlock HorizontalAlignment="Center"
                               FontWeight="Bold"
                               Text="Additional Control Properties to Render" />

                    <DataGrid AutoGenerateColumns="False"
                              ItemsSource="{Binding ControlProperties}">
                        
                        <DataGrid.Columns>
                            <DataGridTemplateColumn CanUserReorder="False"
                                                    CellTemplate="{StaticResource PropertyNameCellTemplate}"
                                                    ClipboardContentBinding="{x:Null}"
                                                    Header="Property" />
                            <DataGridTemplateColumn CanUserReorder="False"
                                                    CellTemplate="{StaticResource PropertyValueCellTemplate}"
                                                    ClipboardContentBinding="{x:Null}"
                                                    Header="Property" />
                            <DataGridTemplateColumn CanUserReorder="False"
                                                    CellTemplate="{StaticResource DeleteCellTemplate}"
                                                    ClipboardContentBinding="{x:Null}"
                                                    Header="Delete"/>
                        </DataGrid.Columns>
                    </DataGrid>

                    <Button HorizontalAlignment="Right"
                            VerticalAlignment="Center"
                            Background="#00000000"
                            BorderBrush="#00000000"
                            Click="btnAddNewUIProperty_Click"
                            Content="+"
                            FontSize="16"
                            Padding="3,-2,3,0"
                            ToolTip="Click to add a new control property." />
                </StackPanel>

                <Grid Grid.Row="10"
                      Grid.ColumnSpan="2"
                      Margin="0,15,0,10"
                      HorizontalAlignment="Right"
                      Grid.IsSharedSizeScope="True">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition SharedSizeGroup="Buttons" />
                        <ColumnDefinition SharedSizeGroup="Buttons" />
                    </Grid.ColumnDefinitions>
                    <Button Height="23"
                            Margin="3"
                            Click="btnOK_Click"
                            Content="OK"
                            Padding="3,0,3,0" />
                    <Button Grid.Column="1"
                            Height="23"
                            Margin="3"
                            Click="btnCancel_Click"
                            Content="Cancel"
                            Padding="3,0,3,0" />
                </Grid>
            </Grid>
        </Border>
    </Grid>
</Window>